package com.hdu.other.dp.gupiao;

public class lc714 {
    class Solution {
        public int maxProfit(int[] prices, int fee) {

            int prepare = -fee - prices[0];
            int ans = 0;

            for (int i = 1; i < prices.length; i++) {
                ans = Math.max(ans, prepare + prices[i]);
                prepare = Math.max(prepare, ans - prices[i] - fee);
            }

            return ans;
        }
    }
}
